<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>生产登记（点击登记）</title>
    <link rel="shortcut icon" href="favicon.ico">
    <link href="/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="/css/font-awesome.min.css?v=4.4.0" rel="stylesheet">
    <link href="/css/animate.css" rel="stylesheet">
    <link href="/css/style.css?v=4.1.0" rel="stylesheet">
    <link href="/bootstraptable/bootstrap-table.css" rel="stylesheet">
</head>
<body>
<div style="color: #0e9aef;">您正在做的业务是：生产管理--内部生产管理--生产登记</div>

<div class="container" style="margin-top: 20px;">
    <div style="text-align: right">
        <button type="button" class="btn btn-default" onclick="javascript:history.back()">返回</button>
    </div>
    <div class="panel panel-default" style="margin-top: 20px;">
        <div class="panel-heading">
                <div class="h3" style="text-align: center">生产派工单</div>
        </div>
        <div class="panel-body">
            <form class="form-horizontal" id="formulated_form">
                <div class="form-group">
                    <div class="col-md-6">
                        <label class="control-label col-md-4">派工单编号：</label>
                        <div class="col-md-8">
                            <input type="text" name="manufactureId" id="manufactureId" readonly class="form-control" style="border: none;background-color: white">
                        </div>
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-md-6">
                        <label class="control-label col-md-4">产品编号：</label>
                        <div class="col-md-8">
                            <input type="text" name="productId" id="productId" readonly class="form-control" style="border: none;background-color: white">
                        </div>
                    </div>
                    <div class="col-md-6">
                        <label class="control-label col-md-4">产品名称：</label>
                        <div class="col-md-8">
                            <input type="text" name="productName" id="productName" readonly class="form-control" style="border: none;background-color: white">
                        </div>
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-md-6">
                        <label class="control-label col-md-4">描述：</label>
                        <div class="col-md-8">
                            <input type="text" name="productDescribe" id="productDescribe" readonly class="form-control" style="border: none;background-color: white">
                        </div>
                    </div>
                    <div class="col-md-6">
                        <label class="control-label col-md-4">数量：</label>
                        <div class="col-md-8">
                            <input type="text" name="amount" id="amount" readonly class="form-control" style="border: none;background-color: white">
                        </div>
                    </div>
                </div>
                <table  style="margin-top: 20px;" class="table table-bordered table-striped" data-toggle="table" id="formulated_table">
                    <thead>
                        <tr>
                            <th data-field="procedureName">工序名称</th>
                            <th data-field="labourHourAmount">设计工时数</th>
                            <th data-field="realLabourHourAmount">实际工时数</th>
                            <th data-field="subtotal">设计工时成本</th>
                            <th data-field="realSubtotal">实际工时成本</th>
                            <th data-field="moduleSubtotal">设计物料成本</th>
                            <th data-field="realModuleSubtotal">实际物料成本</th>
                            <th data-field="y" data-formatter="formatterDesign">本工序登记</th>
                            <th data-field="x" data-formatter="formatterText"></th>
                        </tr>
                    </thead>
                </table>
                <div class="form-group">
                    <div class="col-md-6">
                        <label class="control-label col-md-4">设计工时总成本：：</label>
                        <div class="col-md-8">
                            <input type="text" name="labourCostPriceSum" id="labourCostPriceSum" readonly class="form-control" style="border: none;background-color: white">
                        </div>
                    </div>
                    <div class="col-md-6">
                        <label class="control-label col-md-4">设计物料总成本：：</label>
                        <div class="col-md-8">
                            <input type="text" name="moduleCostPriceSum" id="moduleCostPriceSum" readonly class="form-control" style="border: none;background-color: white">
                        </div>
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-md-6">
                        <label class="control-label col-md-4">实际工时总成本：：</label>
                        <div class="col-md-8">
                            <input type="text" name="realLabourCostPriceSum" id="realLabourCostPriceSum" readonly class="form-control" style="border: none;background-color: white">
                        </div>
                    </div>
                    <div class="col-md-6">
                        <label class="control-label col-md-4">实际物料总成本：：</label>
                        <div class="col-md-8">
                            <input type="text" name="realModuleCostPriceSum" id="realModuleCostPriceSum" readonly class="form-control" style="border: none;background-color: white">
                        </div>
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-md-6">
                        <label class="control-label col-md-4">登记人：</label>
                        <div class="col-md-8">
                            <input type="text" name="register" id="register" readonly class="form-control" style="border: none;background-color: white">
                        </div>
                    </div>
                    <div class="col-md-6">
                        <label class="control-label col-md-4">登记时间：</label>
                        <div class="col-md-8">
                            <input type="text" name="registerTime" id="registerTime" readonly class="form-control" style="border: none;background-color: white">
                        </div>
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-md-6">
                        <label class="control-label col-md-4">复核人：</label>
                        <div class="col-md-8">
                            <input type="text" name="checker" id="checker" readonly class="form-control" style="border: none;background-color: white">
                        </div>
                    </div>
                    <div class="col-md-6">
                        <label class="control-label col-md-4">复核时间：</label>
                        <div class="col-md-8">
                            <input type="text" name="checkTime" id="checkTime" readonly class="form-control" style="border: none;background-color: white">
                        </div>
                    </div>
                </div>
                <form class="form-group">
                    <div class="col-md-6">
                        <label class="control-label col-md-4">备注：</label>
                        <div class="col-md-8">
                            <textarea id="remark" name="remark" rows="3" cols="50" readonly class="form-control" style="border: none;background-color: white;resize: none">
                            </textarea>
                        </div>
                    </div>
                </form>
            </form>
        </div>
    </div>
</div>

<div class="modal fade " id="make_modal">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal">
                    <span>&times;</span>
                </button>
            </div>
            <div class="modal-body">
                <div style="text-align: right">
                    <button type="button" id="finish_btn" class="btn btn-default">确定</button>
                    <button type="button" id="return_btn" class="btn btn-default">返回</button>

                </div>
                <div style="margin-top: 20px;" class="form-inline">
                    请输入本工序合格品数量:<input type="text" name="realAmount" id="realAmount" class="form-control">
                    <input type="hidden" id="realId">
                </div>
            </div>
        </div>
    </div>
</div>

<!-- 全局js -->
<script src="/js/jquery.min.js?v=2.1.4"></script>
<script src="/js/bootstrap.min.js?v=3.3.6"></script>
<script src="/js/plugins/metisMenu/jquery.metisMenu.js"></script>
<script src="/js/plugins/slimscroll/jquery.slimscroll.min.js"></script>
<script src="/js/plugins/layer/layer.min.js"></script>

<!-- 自定义js -->
<script src="/js/hAdmin.js?v=4.1.0"></script>
<script src="/js/currentTime.js"></script>

<!-- 第三方插件 -->
<script src="/js/plugins/pace/pace.min.js"></script>

<!--BootstrapTable-->
<script src="/bootstraptable/bootstrap-table.min.js"></script>
<script src="/bootstraptable/locale/bootstrap-table-zh-CN.min.js"></script>

<script>
    $(function (){
        let makeId=localStorage.getItem("makeId")

        $.post("/manufacture/detail/getIdQueryDesignManufacture",{"makeId":makeId},function (res){
            $("#formulated_form #manufactureId").val(res.manufactureId)
            $("#formulated_form #productId").val(res.productId)
            $("#formulated_form #productName").val(res.productName)
            $("#formulated_form #amount").val(res.amount)
            $("#formulated_form #productDescribe").val(res.productDescribe)
            $("#formulated_form #moduleCostPriceSum").val(res.moduleCostPriceSum)
            $("#formulated_form #realModuleCostPriceSum").val(res.realModuleCostPriceSum)
            $("#formulated_form #labourCostPriceSum").val(res.labourCostPriceSum)
            $("#formulated_form #realLabourCostPriceSum").val(res.realLabourCostPriceSum)
            $("#formulated_form #register").val(res.register)
            $("#formulated_form #registerTime").val(formater(res.registerTime))
            $("#formulated_form #checker").val(res.checker)
            $("#formulated_form #checkTime").val(formater(res.checkTime))
            $("#formulated_form #remark").val(res.remark)
        })

        $.post("/manufacture/detail/getIdQueryManufactureDetails",{"makeId":makeId},function (res){
            for (let i=0;i<res.length;i++){
                $("#formulated_table").bootstrapTable("append",res[i])
            }
        })

        //设置模态框的属性
        $("#make_modal").modal({
            backdrop: false,
            keyboard: false,
            show: false
        })


        $("#make_modal #return_btn").click(function () {
            $("#make_modal").modal("hide")
        })
        $("#make_modal #finish_btn").click(function () {
            let pid= $("#make_modal #realId").val()
            let realAmount= $("#make_modal #realAmount").val()
            $.post("/manufacture/procedure/upd",{"pid":pid,"realAmount":realAmount},function (res){
                if(res){
                    window.location="production_registrationUI"
                }
            })
        })

    })

    function formatterDesign(value,row,index){
        if(row.procedureFinishTag==="G004-0")
        return `<a href="javascript:getById(${row.id})">登记</a>`
        else if(row.procedureFinishTag==="G004-2")
            return `<a href="javascript:getById(${row.id})">登记</a>`
        else if(row.procedureFinishTag==="G004-1")
            return `<a style="color: black">完成</a>`
        else
            return `<a style="color: black">完成</a>`
    }
    function formatterText(value,row,index){
        if(row.procedureTransferTag=="G005-0"){
            return ""
        }else if(row.procedureTransferTag=="G005-1")
            return `<a href="javascript:reg(${row.id});"> 交接登记</a>`
        else if(row.procedureTransferTag=="G005-2")
            return `<a style="color: black">交接完成</a>`

    }

    function getById(gxId){

        localStorage.setItem("gxId",gxId)
        let manId = $("#formulated_form #manufactureId").val()
        localStorage.setItem("manId",manId)
        window.location="produce_process_registrationUI"
    }
    function reg(id){
        $("#make_modal").modal("show")
        $("#make_modal #realId").val(id)

    }
</script>
</body>
</html>